<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="../commn/base.css" />
		<link rel="stylesheet" type="text/css" href="../css/weui.min.css" />
		<link rel="stylesheet" type="text/css" href="../css/jquery-weui.min.css" />
		<link rel="stylesheet" type="text/css" href="../Hui-iconfont/1.0.8/iconfont.css" />
		<style type="text/css">
			body {
				display: -webkit-box;
				-webkit-box-orient: vertical;
				width: 100%;
				background-color: #EFEFF4;
			}
			
			.index {
				min-width: 240px;
			}
			
			.top {
				display: -webkit-box;
				width: 100%;
				height: 40px;
				background-color: #0F88EB;
				position: fixed;
			}
			
			.top>span {
				line-height: 40px;
				text-indent: 1em;
				color: white;
				display: -webkit-box;
				font-size: 18px;
				font-weight: bold;
				-webkit-box-flex: 1;
			}
			
			.back {
				color: white;
				font-size: 18px;
				margin-left: 15px;
				line-height: 40px;
			}
			
			.title {
				margin: 10px;
				height: 40px;
				outline: none;
				border-bottom: 1px solid #EEEEEE;
			}
			
			.content {
				margin-bottom: 60px;
				border-bottom: 1px solid #EEEEEE;
			}
			
			.data {
				display: -webkit-box;
				min-height: 20px;
				margin: 3px;
				border: 1px solid #EEEEEE;
				background-color: white;
				padding-bottom: 10px;
				padding-right: 20px;
			}
			
			.detail_photo {
				width: 50px;
				height: 50px;
				margin: 10px;
				border-radius: 40px;
				border: 1px solid #EEEEEE;
				overflow: hidden;
			}
			
			.detail_photo img {
				width: 50px;
				height: 50px;
			}
			
			.detail_name {
				-webkit-box-flex: 1;
			}
			
			.detail_name>p {
				height: 30px;
			}
			
			.detail_name>p:nth-child(1) {
				font-weight: bold;
				line-height: 40px;
			}
			
			.detail_name>p:nth-child(2) {
				font-size: 14px;
				color: #999999;
				min-height: 60px;
				padding: 10px;
				word-break: break-all;
			}
			
			.detail_name>p:nth-child(2)>span:nth-child(2) {
				margin-right: 10px;
				float: right;
			}
			
			.add {
				width: 70px;
				margin: 20px 10px;
				text-align: center;
				font-weight: bold;
				color: #0F88EB;
				height: 30px;
				line-height: 30px;
				border-radius: 8px;
				border: 2px solid #0F88EB;
			}
			
			.detail_article {
				margin: 3px;
				border: 1px solid #EEEEEE;
				min-height: 400px;
				background-color: white;
				margin-bottom: 65px;
			}
			
			.detail_article p:nth-child(1) {
				font-size: 18px;
				font-weight: bold;
			}
			
			.bottom {
				display: -webkit-box;
				width: 100%;
				height: 60px;
				position: fixed;
				bottom: 0px;
				background-color: white;
			}
			
			.comment_text {
				height: 58px;
				padding: 8px;
				-webkit-box-flex: 1;
			}
			
			.comment_texts {
				outline: none;
				width: 100%;
				height: 40px;
				border: none;
				border-bottom: 1px solid #0F88EB;
			}
			
			.comment_send {
				outline: none;
				border-radius: 10px;
				width: 60px;
				height: 40px;
				margin-top: 8px;
				color: white;
				border: 1px solid #0F88EB;
				background-color: #0F88EB;
			}
		</style>
	</head>

	<body>
		<div class="index">
			<div class="top">
				<i class="back Hui-iconfont Hui-iconfont-slider-left" @click="back"></i>
				<span class="">
					评论
				</span>
			</div>
			<div style="height: 40px;"></div>
			<div class="content">
				<div class="data" v-for="lee in message">
					<div class="detail_photo">
						<img src="../common/img/1.jpg" />
					</div>
					<div class="detail_name">
						<p v-html="lee.p_id"></p>
						<p><span v-html="lee.p_text"></span><span v-html="lee.p_time"></span></p>
					</div>
				</div>

			</div>
			<div class="bottom">
				<div class="comment_text">
					<input type="text" class="comment_texts" placeholder="请输入评论内容" />
				</div>
				<input type="button" class="comment_send" @click="pinglun()" value="评论" />
			</div>
		</div>
		<script src="../js/yanred.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var newVue = new Vue({
				el: "body",
				data: {
					message: [],
					vueindex: ""
				},
				methods: {
					back: function() {
						location.href = "../zhuhu_detail/detail.html?id=" + newVue.vueindex;
					},
					pinglun:function(){
						pinglun()
					}
				}
			})
			var ss;
			var dd;
			var index;
			var reg = new RegExp("(^|&)" + "id" + "=([^&]*)(&|$)", "i");
			var r = window.location.search.substr(1).match(reg);
			if(r != null) {
				console.log(unescape(r[2]));
				index = unescape(r[2]);
				newVue.vueindex = unescape(r[2]);
			} else {
				console.log(null);
			};
			$.ajax({
				type: 'get',
				//async:false,
				url: "http://v2.mashupcloud.cn/developer/auth.do",
				data: {
					appkey: 'FvWrIYOQoTUYVbscUNQoQAVqsLnZqKEN',
					appsecret: 'ugCfcSmyLkcbCGfIuFOPEgTgPQPbyJSE'

				},
				success: function(json) {
					//		            console.log(json);
					ss = JSON.parse(json)[1];
					dd = JSON.parse(json)[2];
					console.log('获得token成功');
					$.ajax({
						type: 'get',
						url: "http://v2.mashupcloud.cn/SQL/sele_ping/",
						data: {
							appid: dd,
							token: ss,
							name: 'sele_ping',
							_v1: index
						},
						success: function(json) {
							console.log(JSON.parse(json));
							newVue.message = JSON.parse(json)[2];
						},
						error: function(json) {
							console.log("err:" + json);
						}
					});
				},
				error: function(json) {
					console.log("err:" + json);
				}
			});
			//			var a = $(".good").html();
			//			$(".good").click(function() {
			//				a++;
			//				$(".good").html(a);
			//			});
			//评论部分
			var year = new Date();
			var nian = year.getFullYear();
			var yue = (year.getMonth() + 1) < 10 ? "0" + (year.getMonth() + 1) : year.getMonth() + 1;
			var day = year.getDate() < 10 ? "0" + year.getDate() : year.getDate();
			var str1 = nian + "-" + yue + "-" + day;

			function pinglun() {
				var id = sessionStorage.getItem("id");
				if(id == null) {
					alert("需要登录才能进行相关操作")
					location.href = "../zhihu_index/index.html"
				}else{

				var ss;
				var dd;
				$.ajax({
					type: 'get',
					//async:false,
					url: "http://v2.mashupcloud.cn/developer/auth.do",
					data: {
						appkey: 'FvWrIYOQoTUYVbscUNQoQAVqsLnZqKEN',
						appsecret: 'ugCfcSmyLkcbCGfIuFOPEgTgPQPbyJSE'

					},
					success: function(json) {
						//		            console.log(json);
						ss = JSON.parse(json)[1];
						dd = JSON.parse(json)[2];
						console.log('获得token成功');
						$.ajax({
							type: 'get',
							url: "http://v2.mashupcloud.cn/SQL/into_p/",
							data: {
								appid: dd,
								token: ss,
								name: 'into_p',
								_v1: index,
								_v2: $(".comment_texts").val(),
								_v3: sessionStorage.getItem("id"),
								_v4: str1
							},
							success: function(json) {
								console.log(JSON.parse(json));
								alert("评论成功");
								location.reload();
							},
							error: function(json) {
								console.log("err:" + json);
							}
						});
					},
					error: function(json) {
						console.log("err:" + json);
					}
				});

			};
			}
		</script>

	</body>

</html>